#include<iostream>

using namespace std;
#define int long long
const int N = 1e5 + 10;
int n , q;
int a[N];
int s[N];
signed main()
{
    cin >> n >> q;
    for(int i = 1;i <= n;i ++) cin >> a[i];
    for(int i = 1;i <= n;i ++) s[i] = s[i - 1] + a[i];
    while(q--)
    {
        int l , r;
        cin >> l >> r;
        cout << s[r] - s[l - 1] << endl;
    }
    return 0;
}